package com.police.activity;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;
import android.widget.PopupWindow;

import com.baidu.mapapi.map.ItemizedOverlay;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.OverlayItem;
import com.baidu.mapapi.map.PopupOverlay;
import com.baidu.platform.comapi.basestruct.GeoPoint;

import java.io.IOException;


/**
 * Created by dingzhongchang on 13-6-3.
 */
class LocOverlay extends ItemizedOverlay<OverlayItem> {
    private Context mContext = null;
    PopupWindow JizhanClickPop;
    OverlayItem mCurItem;
    Bitmap[] bmps = new Bitmap[1];
    PopupOverlay pop;

    public LocOverlay(Drawable marker, Context context, MapView mapView) {
        super(marker, mapView);
        this.mContext = context;
        try {
            bmps[0] = BitmapFactory.decodeStream(context.getAssets().open("go_to.png"));
        } catch (IOException e) {
            e.printStackTrace();
        }


    }

    public void setPop(PopupOverlay pop){
        this.pop=pop;
    }
    public OverlayItem getCurItem() {
        return mCurItem;
    }

    protected boolean onTap(int index) {
        OverlayItem item = getItem(index);
        mCurItem = item;
//        Bitmap[] bitMaps={
//                BMapUtil.getBitmapFromView(popupLeft),
//                BMapUtil.getBitmapFromView(popupInfo),
//                BMapUtil.getBitmapFromView(popupRight)
//        };
        pop.showPopup(bmps, item.getPoint(), 42);
        return true;
    }

    public boolean onTap(GeoPoint pt, MapView mapView) {
        if (pop != null) {
            pop.hidePop();
        }
        super.onTap(pt, mapView);
        return false;
    }


}
